<?php
require_once 'BaseController.php';

/**
 * 物件詳細
 *
 * @package apamanshop
 * @author suzuki-h@systemsoft.co.jp
 * @copyright コピーライト(要確認)
 */
class Rstdtl_BukendtlController extends Rstdtl_BaseController
{

	private $_campaignList;
	private $_hiddenTags;
	private $_hiddenTagsInquiry;

   	/**
	* 物件詳細ページ表示のメインアクション
	*
	* @access public
	* @return void
	*/
	public function indexAction()
	{
		/*
		 * 基本情報設定
		 */
		// タイトル
		//$this->setTitle('賃貸情報アパマンショップ[物件詳細]');
		// アンカー
		//$this->setAnchorLink('<a href="#">ページトップへ</a>');
		
		// モデル生成
		$this->_model_buken = new Rstdtl_Model_Bukendtl();	// 物件詳細
		$this->_model_tenpo = new Rstdtl_Model_Tenpodtl();	// 店舗詳細
		
		// 外部モデル呼び出し設定
		$loader = new Zend_Application_Module_Autoloader(array(
			'namespace' => 'Rstobi',
			'basePath' => APPLICATION_PATH . '/modules/rstobi',
		));
		$this->_model_recommend  = new Rstobi_Model_BknRecommend();		// レコメンド
		$this->_model_rireki     = new Rstobi_Model_BknRireki();		// 前回閲覧履歴・お気に入り物件

		$newTemplate = false;
		// テンプレート設定
		// OEM判定 法人判定
		if($this->_model_buken->isOem($this->_params) || $this->_model_buken->isAsnnet($this->_params) ){
			// ヘッダ・フッター非表示
			$this->setXPassThroutgh();
			// メインテンプレート
			$disp_tpl = APPLICATION_PATH . '/modules/rstdtl/views/scripts/bukendtl_nohead.tpl';
		// 法人サイトの場合はヘッダーフッターなし
		}else if($this->_params['SrhKbn'] == Apm_Config_Search::SRHKBN_SYATAKU){
			// ヘッダ・フッター非表示
			$this->setXPassThroutgh();
			// 法人サイト用テンプレート
			$disp_tpl = APPLICATION_PATH . '/modules/rstdtl/views/scripts/bukendtl_for_asnnet.tpl';
		}else{
			// メインテンプレート
			if (Apm_Config_Search::RENEW_2012) {
				$disp_tpl = APPLICATION_PATH . '/modules/rstdtl/views/scripts/bukendtl_new.tpl';
				$newTemplate = true;
				$this->_import_seo_search = true;
				$this->_data['seo_search_data']['PREF'] = Apm_Seo::getRandomPref(5);
				$this->_data['seo_search_data']['KODAWARI'] = Apm_Seo::getSeoImpKodawari(3,3);
				$this->_data['seo_search_tpl'] = APPLICATION_PATH . '/modules/common/views/scripts/seo_search.tpl';
			} else {
				$disp_tpl = APPLICATION_PATH . '/modules/rstdtl/views/scripts/bukendtl.tpl';
			}
		}
		
		// GoogleMapKey
		$this->_data['googlemap']['key'] = $this->_config['googlemap']['key'];
		
		if ($newTemplate) {
			// CSS
			$this->addMetaCss('/common_new/css/sub.css', array('media' => 'screen, projection, tv'));
			//$this->addMetaCss('/common_new/css/sub.css', array('media' => 'all'));
			$this->addMetaCss('/common_new/css/print.css', array('media' => 'print'));
			$this->addMetaCss('/common_new/css/thickbox.css', array('type' => 'text/css', 'rel' => 'stylesheet', 'media' => 'screen, projection, tv, print'));
			// JavaSript
			//$this->addMetaJs('http://maps.google.com/maps?file=api&v=2&key='.$this->_data['googlemap']['key'], array('charset' => 'utf-8'));
			$this->addMetaJs('/common_new/js/import_dtl.js');
			$this->addMetaJs('/app/js/rstdtl/mapple.js');
			$this->addMetaJs('/app/js/mapple/lib/Mapple.js');
			$this->addMetaJs('/app/js/mapple/lib/slider.js');
			$this->addMetaJs('/app/js/mapple/lib/scrollmap.js');
		} else {
			// CSS
			$this->addMetaCss('/css/common/import.css' ,array('media' => 'all'));
			$this->addMetaCss('/css/search/search.css',array('media' => 'all'));
			$this->addMetaCss('/css/search/print.css',array('media' => 'print'));
			$this->addMetaCss('/css/search/thickbox.css',array('type' => 'text/css'));
			//JavaSriptの定義（アプリ）
			//$this->addMetaJs('http://maps.google.com/maps?file=api&v=2&key='.$this->_data['googlemap']['key'] ,array('charset' => 'utf-8'));
			$this->addMetaJs('/app/js/rstdtl/bukendtl.js');
			$this->addMetaJs('/app/js/search/Chizusearch.js');
			//$this->addMetaJs('/app/js/search/detail.js');
			//$this->addMetaJs('/app/js/search/thickbox.js');
			$this->addMetaJs('/app/js/rstdtl/constant.js');
			//$this->addMetaJs('/app/js/rstdtl/ew.js');
			//$this->addMetaJs('/app/js/rstdtl/gmap.js');
			$this->addMetaJs('/app/js/rstdtl/mapple.js');
			$this->addMetaJs('/app/js/mapple/lib/Mapple.js');
			$this->addMetaJs('/app/js/mapple/lib/slider.js');
			$this->addMetaJs('/app/js/mapple/lib/scrollmap.js');
			$this->addMetaJs('/app/js/jquery.validation.js');
			$this->addMetaJs($this->_config['apm']['baseurl'] . 'js/search/minmax-1.0.js');
		}

		// BLOCKの生成
		$this->_data['buken_block']	= array();
		$this->_data['tenpo_block']	= array();
		$this->_data['tenpoDtl']	= array();

		// 部屋コード取得
		$heyaCd = explode(",",$this->_params['ID']);
		$this->_params['HeyaCd'] = $heyaCd[0];

		// タイトル、Description、Keywords設定
        $meta_data = Apm_Bukkenurl::setCommonMeta("detail", $this->_params);
		$this->setDescription($meta_data['description']);
		$this->setKeywords($meta_data['keywords']);
		$this->setTitle($meta_data['title']);
		$this->_data['h1_title']   = $meta_data['page_title'];
		$this->_data['read_title'] = $meta_data['description'];
		// アンカーリンク
		$this->setAnchorLink2(ltrim($meta_data["page_title"].'&nbsp;',' ').'ページトップへ');
		//$this->setAnchorLink('<p class="pagetop"><a href="javascript:backToTop()"><strong>'.ltrim($meta_data["page_title"].' ',' ').'ページのトップへ</strong></a></p>');

		/* 2011/07/22　AKBｷｬﾝﾍﾟｰﾝ：加盟店ﾒﾝﾊﾞｰｻｲﾄ追加対応 */
		//加盟店ページより遷移時はヘッダを付与する
		if($this->_params['shoppage']){
			// 外部モデル呼び出し設定
			$loader = new Zend_Application_Module_Autoloader(array(
				'namespace' => 'Shop',
				'basePath' => APPLICATION_PATH . '/modules/shop',
			));
			$this->_model_shop = new Shop_Model_Detail();
			// 店舗詳細情報取得
			$shopDtlList = $this->_model_shop->getList($this->_params);
			// 表示用に変換
			$this->_data['shopDtl'] = $this->_model_shop->convertData($shopDtlList[0]);
	    	// Block設定
	        $this->_data['shoppage_header_block']   = $this->_shoppage_header_helper->getBlock($this->_data);
	        $this->_data['shoppage_footer_block']   = $this->_shoppage_footer_helper->getBlock($this->_data);
		}

		// OEM または 法人は表示しない
		if( !$this->_model_buken->isOem($this->_params) && !$this->_model_buken->isAsnnet($this->_params)){
			/*** レコメンド検索=>条件が近い物件 ***/
// 2012/01/09 レコメンド非表示
$this->_data['recommend'] = array();
//			// レコメンド物件情報取得
//			$this->_data['recommend'] = $this->_model_recommend->getRecommendList($this->_params);
//			// 表示用にコンバート
//			$this->_data['recommend'] = $this->_model_recommend->convertRecommendList($this->_data['recommend']);
//			// リード文生成
//			if (!empty($this->_data['recommend'])) {
//				$this->_data['recommend_read_text'] = $meta_data["COMMENT"]."と似た条件から賃貸情報を探したい方はこちらから";
//			}
//			// レコメンドブロック生成
			$this->_data['recommend_block'] = $this->_recommend_helper->getBlock($this->_data);

			/*** 周辺の物件 ***/
// 2012/01/09 周辺の物件非表示
$this->_data['vicinity'] = array();
//			// 周辺の物件情報取得
//			$this->_data['vicinity'] = $this->_model_recommend->getVicinityList($this->_params);
//			// 表示用にコンバート
//			$this->_data['vicinity'] = $this->_model_recommend->convertRecommendList($this->_data['vicinity']);
//			// リード文生成
//			if (!empty($this->_data['vicinity'])) {
//				$this->_data['vicinity_read_text'] = $meta_data["COMMENT"]."の周辺から賃貸情報を探したい方はこちらから";
//			}
			// 周辺の物件ブロック生成
			$this->_data['vicinity_block'] = $this->_vicinity_helper->getBlock($this->_data);

			/*** 前回閲覧履歴検索 ***/
			// 履歴取得
			$oemCd  = $this->_params['OemCd'];
			$useKbn = (array_key_exists("UseKbn",$this->_params)) ? $this->_params['UseKbn'] : "0";
			$this->_data['rireki'] = $this->_model_rireki->getRirekihyoujiData($oemCd, $useKbn);
			// 表示用にコンバート
			$this->_data['rireki'] = $this->_model_rireki->convertRirekiData($this->_data['rireki']);
			// 前回閲覧履歴ブロック生成
			if ($newTemplate) {
				$this->_rireki_helper = $this->getApmHelper('rireki_new.tpl');
			}
			$this->_data['rireki_block']  = $this->_rireki_helper->getBlock($this->_data);

			/*** お気に入り物件 ***/
			$this->_data['okiniiri'] = array();
			// お気に入り物件取得
			$this->_data['okiniiri'] = $this->_model_rireki->getOkiniirihyoujiData($this->getCurrentUserEid());
			// 表示用にコンバート
			$this->_data['okiniiri'] = $this->_model_rireki->convertRirekiData($this->_data['okiniiri']);
			// お気に入り物件ブロック生成
			$this->_data['okiniiri_block']  = $this->_okiniiri_helper->getBlock($this->_data);
		}

		// 物件件数取得
		//$this->_data['bukenCnt'] = $this->_model_buken->getBukenDtlCount($this->_params);

		// 物件詳細データの生成
		$this->_data['bukenDtl'] = $this->_model_buken->getBukenDtlListData($this->_params);
		
		// 表示用データに変換
		$this->_model_buken->convertData($this->_config,$this->_data['bukenDtl'],$this->_params);

		// PV増分処理用 GENRU_FLAG取得
		$genruFlg = $this->_model_buken->getGenruFlg($this->_params);

		// キャンペーン情報生成
		$this->makeCampaignParams();
		// hiddenタグ生成
		$this->makeHiddenTags(count($this->_data['bukenDtl']));

		$apalog_pref = array();
		// 部屋に紐づく情報作成
		for ($i=0;$i<count($this->_data['bukenDtl']);$i++)
		{
			// インデックス指定
			$this->_data['bukenDtl'][$i]['index'] = $i;

			// 閲覧履歴作成
			$this->_model_buken->setReirekiCookie($this->_data['bukenDtl'][$i]);

			// 物件QRコード生成
			$qrUrl = $this->_data['bukenDtl'][$i]['MOBILE_URL'];
	        $this->_data['bukenDtl'][$i]['qr'] = $this->_model_buken->getQrArray($qrUrl,Apm_Config_Rstdtl::IMG_SIZE_BUKEN_QR);
	        $this->_data['bukenDtl'][$i]['qr_helper'] = $this->_qr_helper->getBlock($this->_data['bukenDtl'][$i]);

			// H2タグ
			if (!empty($this->_data['h1_title'])) {
				$this->_data['bukenDtl'][$i]['block_title'] = $this->_data['h1_title'].' 物件情報';
			}
			$ditail_title = "";
			if (empty($this->_data['bukenDtl'][$i]['T03_PR01']) && empty($this->_data['bukenDtl'][$i]['T03_PR02']))
			{
				// PRコメントが無い場合
				$ditail_title  = $this->_data['bukenDtl'][$i]['T03_JYUUSHO_TEXT'] . " " . $this->_data['bukenDtl'][$i]['T03_TATEMONO_TYPE'] . " " . $this->_data['bukenDtl'][$i]['T03_MADORI'];
			}
			else
			{
				// PR文字列連結
				$ditail_title = $this->_data['bukenDtl'][$i]['T03_PR01'] . " " . $this->_data['bukenDtl'][$i]['T03_PR02'];
				$ditail_title = Apm_Util::replaceUnicode($ditail_title);
				if(mb_strlen($ditail_title) > 30) {
					$ditail_title = mb_substr($ditail_title, 0, 30) . "…";
				}
			}
			$ditail_title .= " " . $this->_data['bukenDtl'][$i]['T03_ORIGINAL_HEYA_CD01'] . "-" . $this->_data['bukenDtl'][$i]['T03_TENPO_CD'];
			$this->_data['bukenDtl'][$i]['ditail_title'] = $ditail_title;

			// SSL
			$this->_data['bukenDtl'][$i]['sslurl'] = $this->_config['apm']['ssl']['baseurl'];
	        //===以下問い合わせ用パラメータ===
	        $this->_data['bukenDtl'][$i]['allCampList'] = $this->_campaignList;
	        $this->_data['bukenDtl'][$i]['HeyaID'] = $this->_params['ID'];
	        $this->_data['bukenDtl'][$i]['ID'] = $this->_params['ID'];
			if(empty($this->_params['UserComName']) && !empty($this->_params['strComName'])) {
				// 法人サイト（初回）の場合
				if ($this->_params['ComGenruFlg'] == '15') {
					// 東急リロケーション（受託）
					$this->_data['bukenDtl'][$i]['UserComName'] = "";
				} else if ($this->_params['ComGenruFlg'] == '24') {
					// 東急リロケーション（ＪＴグループ）
					$this->_data['bukenDtl'][$i]['UserComName'] = "ＪＴグループ";
				} else {
					// 上記以外
					$this->_data['bukenDtl'][$i]['UserComName'] = $this->_params['strComName'];
				}
			} else {
				$this->_data['bukenDtl'][$i]['UserComName'] = $this->_params['UserComName'];
			}
	        $this->_data['bukenDtl'][$i]['NameSei'] = $this->_params['NameSei'];
	        $this->_data['bukenDtl'][$i]['NameMei'] = $this->_params['NameMei'];
	        $this->_data['bukenDtl'][$i]['Mail'] = $this->_params['Mail'];
	        $this->_data['bukenDtl'][$i]['Mail1'] = $this->_params['Mail1'];
	        $this->_data['bukenDtl'][$i]['Mail2'] = $this->_params['Mail1'];
	        $this->_data['bukenDtl'][$i]['Tel1'] = $this->_params['Tel1'];
	        $this->_data['bukenDtl'][$i]['Tel2'] = $this->_params['Tel2'];
	        $this->_data['bukenDtl'][$i]['Tel3'] = $this->_params['Tel3'];
	        $this->_data['bukenDtl'][$i]['NeedTimeKbn'] = $this->_params['NeedTimeKbn'];
	        $this->_data['bukenDtl'][$i]['Fax1'] = $this->_params['Fax1'];
	        $this->_data['bukenDtl'][$i]['Fax2'] = $this->_params['Fax2'];
	        $this->_data['bukenDtl'][$i]['Fax3'] = $this->_params['Fax3'];
	        $this->_data['bukenDtl'][$i]['Inquiry1'] = $this->_params['Inquiry1'];
	        $this->_data['bukenDtl'][$i]['Inquiry2'] = $this->_params['Inquiry2'];
	        $this->_data['bukenDtl'][$i]['Inquiry3'] = $this->_params['Inquiry3'];
	        $this->_data['bukenDtl'][$i]['Inquiry4'] = $this->_params['Inquiry4'];
	        $this->_data['bukenDtl'][$i]['Inquiry5'] = $this->_params['Inquiry5'];
	        $this->_data['bukenDtl'][$i]['Comment'] = $this->_params['Comment'];
	        $this->_data['bukenDtl'][$i]['CampaignAgechau'] = $this->_params['CampaignAgechau'];
	        $this->_data['bukenDtl'][$i]['ComId'] = $this->_params['ComId'];
	        $this->_data['bukenDtl'][$i]['OemCd'] = $this->_params['OemCd'];
	        $this->_data['bukenDtl'][$i]['UseKbn'] = $this->_params['UseKbn'];
	        $this->_data['bukenDtl'][$i]['SrhKbn'] = $this->_params['SrhKbn'];
	        //問合せ対象物件コード(確認画面から戻った際に値を復元する物件を判別するため)
	        $this->_data['bukenDtl'][$i]['cnfBukkenCd'] = $this->_params['BukkenCd'];
	        //hiddenタグ
	        $this->_data['bukenDtl'][$i]['hiddenTags'] = $this->_hiddenTags;
	        //===問い合わせ用パラメータここまで===
	        $this->_data['bukenDtl'][$i]['kodawariData'] = $this->_params['kodawariData'];
	        // 物件詳細kodawariData処理変更
	        $this->_data['bukenDtl'][$i]['InquryHiddenTag'] = $this->_hiddenTagsInquiry;
			// 2011/04/02 災害時支援住宅対応
			$this->_data['bukenDtl'][$i]['sienJutaku'] = $this->_params['sienJutaku'];

			// 同一建屋の部屋情報取得
			$this->_data['bukenDtl'][$i]['heya'] = $this->_model_buken->getTateyaHeya($this->_data['bukenDtl'][$i]);
			// 表示用データに変換
			$this->_model_buken->convertData($this->_config,$this->_data['bukenDtl'][$i]['heya'],$this->_params);

			// 部屋に紐づく店舗情報取得
			$this->_data['bukenDtl'][$i]['tenpo'] = $this->_model_tenpo->getTenpoDtlData($this->_data['bukenDtl'][$i]);
			$this->_model_tenpo->convertData($this->_config,$this->_data['bukenDtl'][$i]['tenpo']);

			//AKBクッキー情報 SS y-sakakibara
	        $this->_data['bukenDtl'][$i]['lpCampaignCd'] = $_COOKIE['lp_campaign_cd'];
	        $this->_data['bukenDtl'][$i]['webcallingType'] = $_COOKIE['webcalling_type'];
			//AKBクッキー情報 SS y-sakakibara

			// 店舗情報テンプレート用配列作成
			$originalHeyaCd = $this->_data['bukenDtl'][$i]['T03_HEYA_CD'];		// 名寄せ解除
			//$originalHeyaCd = $this->_data['bukenDtl'][$i]['T03_ORIGINAL_HEYA_CD01'];
			$this->_data['tenpoDtl'][$originalHeyaCd]['TENPO_DATA'] = $this->_data['bukenDtl'][$i]['tenpo'];

			// インデックス指定
			$this->_data['tenpoDtl'][$originalHeyaCd]['index'] = $i;

			// 店舗毎の処理各種
			for ($j=0;$j<count($this->_data['tenpoDtl'][$originalHeyaCd]['TENPO_DATA']);$j++)
			{
				// PV増分処理
				$this->_model_buken->S_RegPageViewLog($this->_data['tenpoDtl'][$originalHeyaCd]['TENPO_DATA'][$j]['M05_TENPO_CD'], 0, $genruFlg, $this->_data['bukenDtl'][$i]['T03_ORIGINAL_HEYA_CD01'], 1);

				// 店舗QRコード生成
				$qrUrl = $this->_config['apm']['baseurl'].Apm_Config_Rstdtl::URL_MOBILE_TENPODTL .$this->_data['tenpoDtl'][$originalHeyaCd]['TENPO_DATA'][$j]['M05_TENPO_CD'];
		        $this->_data['tenpoDtl'][$originalHeyaCd]['TENPO_DATA'][$j]['qr'] = $this->_model_buken->getQrArray($qrUrl,Apm_Config_Rstdtl::IMG_SIZE_TENPO_QR);
		        $this->_data['tenpoDtl'][$originalHeyaCd]['TENPO_DATA'][$j]['qr_helper'] = $this->_qr_helper->getBlock($this->_data['tenpoDtl'][$originalHeyaCd]['TENPO_DATA'][$j]);
			}

			$this->_data['tenpoDtl'][$originalHeyaCd]['ComId'] = $this->_params['ComId'];
			// 不適切物件URL設定
			$this->_data['tenpoDtl'][$originalHeyaCd]['CLAIME_URL'] = $this->_config['apm']['ssl']['baseurl'].
																	  Apm_Config_Rstdtl::URL_CLAIME_URL.
																	  "?BukkenCd=".$this->_data['bukenDtl'][$i]['CONVERT_T03_ORIGINAL_HEYA_CD01'].
																	  "&ShopCd=".$this->_data['bukenDtl'][$i]['T03_TENPO_CD'];
			// WEBCALLINGNO設定
			$this->_data['tenpoDtl'][$originalHeyaCd]['FREE_CALLING'] = $this->_data['bukenDtl'][$i]['FREE_CALLING'];
			$this->_data['tenpoDtl'][$originalHeyaCd]['CONVERT_CONNECTION_NO'] = $this->_data['bukenDtl'][$i]['CONVERT_CONNECTION_NO'];

			// Firefoxの場合、空のパラメータが飛んでくるため削除
			if(array_key_exists('',$this->_params))
			{
				unset($this->_params['']);
			}
			// hiddenタグ設定
			$this->_data['tenpoDtl'][$originalHeyaCd]['hiddenTag'] = Apm_Util::generateHiddenTag($this->_params);

			/*** 関連カテゴリ ***/
			$this->_data['k_category'][$originalHeyaCd] = Apm_Seo::generateKanrenCategoryBlock($this->_data['bukenDtl'][$i]);

			// アパログ用都道府県コード集計
			$apalog_pref['PrefCd'][] =  $this->_data['bukenDtl'][$i]['T03_TODOUFUKEN_CD'];
		}
		// アパログブロック生成
		if (!empty($apalog_pref)) {
			$apalog_pref['PrefCd'] = array_unique($apalog_pref['PrefCd']);
			Apm_Seo::generateApalogBlock($this->_data, $apalog_pref);
			if ($newTemplate) {
				$this->_apalog_helper = $this->getApmHelper('apalog_new.tpl');
			}
			$this->_data['apalog_block'] = $this->_apalog_helper->getBlock($this->_data);
		}

		// 部屋毎のテンプレート生成
		foreach ($this->_data['bukenDtl'] as $bukenData)
		{
			if ($newTemplate) {
				$this->_bukensyosai_helper = $this->getApmHelper('bukendtl_new.tpl');
				$this->_tenposyosai_helper = $this->getApmHelper('tenpodtl_new.tpl');
				$this->_k_category_helper  = $this->getApmHelper('kanren_category_new.tpl');
			}
			// 物件別詳細BOLCK
			$this->_data['buken_block'][$bukenData['T03_HEYA_CD']]['BUKEN_DTL'] = $this->_bukensyosai_helper->getBlock($bukenData);		// 名寄せ解除
			//$this->_data['buken_block'][$bukenData['T03_ORIGINAL_HEYA_CD01']]['BUKEN_DTL'] = $this->_bukensyosai_helper->getBlock($bukenData);
			// 物件別店舗詳細BLOCK
			$this->_data['tenpo_block'][$bukenData['T03_HEYA_CD']] = $this->_tenposyosai_helper->getBlock($this->_data['tenpoDtl'][$bukenData['T03_HEYA_CD']]);		// 名寄せ解除
			//$this->_data['tenpo_block'][$bukenData['T03_ORIGINAL_HEYA_CD01']] = $this->_tenposyosai_helper->getBlock($this->_data['tenpoDtl'][$bukenData['T03_ORIGINAL_HEYA_CD01']]);
			// 関連カテゴリBLOCK
			if (!empty($this->_data['k_category'][$bukenData['T03_HEYA_CD']])) {
				$this->_data['k_category_block'][$bukenData['T03_HEYA_CD']] = $this->_k_category_helper->getBlock($this->_data['k_category'][$bukenData['T03_HEYA_CD']]);
			} else {
				$this->_data['k_category_block'][$bukenData['T03_HEYA_CD']] = "";
			}
		}

		// 部屋がない場合
		if(empty($this->_data['bukenDtl']))
		{
			// 2012/05/29 Add/Update H.Imamura 物件詳細404出力
			// 404ヘッダー出力
			$this->_404_header = true;
			
			// SEOタグ削除
			$this->_data['h1_title'] = '';
			$this->_data['read_title'] = '';
			
			// 情報誌No検索
			if(array_key_exists("SchNo", $this->_params) && $this->_params["SchNo"] != ""){
				$this->_data['title'] = "サーチNo.". $this->_params["SchNo"].Apm_Config_Rstdtl::TITLE_NO_DATA_JYOHOSHINO;
				$this->_data['msg']   = Apm_Config_Rstdtl::MSG_NO_DATA_JYOHOSHINO;
			// 通常検索
			}else{
				$this->_data['title'] = Apm_Config_Rstdtl::TITLE_NO_DATA_NORMAL;
				$this->_data['msg']   = Apm_Config_Rstdtl::MSG_NO_DATA_NORMAL;
			}
			
			if ($newTemplate) {
				$this->_no_data_helper = $this->getApmHelper('no_data_new.tpl');
			}
			$this->_data['buken_block'][0]['BUKEN_DTL'] = $this->_no_data_helper->getBlock($this->_data);
			
			// パンくず
			$this->_breadcrumb->reset();
			$this->_breadcrumb->add(Apm_Config_Search::BREADCRUMB_TOP, $this->_config['apm']['baseurl']);
			$this->_breadcrumb->add('物件詳細', '');
			$this->setBreadCrumb($this->_breadcrumb->generateBreadcrumb());
		}
		else
		{
			if ($newTemplate && count($this->_data['bukenDtl'])==1) {
				// META再セット
				$buken_name = $this->_data['bukenDtl'][0]['T03_TENPO_CD'].'／'.$this->_data['bukenDtl'][0]['T03_TODOUFUKEN'].$this->_data['bukenDtl'][0]['T03_SHIKUCHOUSON'];
				//$buken_name = '（物件番号：'.$this->_data['bukenDtl'][0]['T03_ORIGINAL_HEYA_CD01'].'-'.$this->_data['bukenDtl'][0]['T03_TENPO_CD'].'）';
				$buken_addr = $this->_data['bukenDtl'][0]['T03_TODOUFUKEN'].$this->_data['bukenDtl'][0]['T03_SHIKUCHOUSON'];
				//$buken_city = $this->_data['bukenDtl'][0]['T03_SHIKUCHOUSON'];
				
				$this->setTitle($buken_name.'の賃貸物件'.Apm_Config_Seo::TITLE_ADDTAIL);
				$this->setDescription($buken_name.'の物件詳細。'.Apm_Config_Seo::DESCRIPTION_ADDTAIL, false);
				$this->setKeywords($buken_addr.','.Apm_Config_Seo::KEYWORD_ADDTAIL);
				$this->_data['h1_title'] = $buken_name."の賃貸物件。".Apm_Config_Seo::H1_ADDTAIL;
				$this->_data['unique_text'] = $buken_name."の賃貸住宅・賃貸マンション・賃貸アパートの検索はアパマンショップ！ペット相談可物件や、敷金礼金ダブル0の賃貸物件など、アパマンショップならではの情報が満載です。<br />"
				                            . "日本最大級のネットワークで".$buken_name."の賃貸物件、賃貸マンション、賃貸アパートを探せます。".Apm_Config_Seo::UNIQUE_TEXT_ADDTAIL;
				
				// ランキングリンクブロック生成
				// 初期化
				$rank_data = array();
				// テンプレート
				$ranking_block = $this->getApmHelper('search/views/helpers/seo_ranking_leftpanel.tpl');
				// ** こだわり取得 **
				$rank_data['RANK_KODAWARI'] = Apm_Seo::getSeoRankingKodawari(5, 8, $this->_data['bukenDtl'][0]['T03_TODOUFUKEN_CD']);
				// ** 建物種別取得 **
				$rank_data['RANK_TYPE']     = Apm_Seo::getSeoRankingType(array(), $this->_data['bukenDtl'][0]['T03_TODOUFUKEN_CD']);
				// ブロック生成
				$this->_data['ranking_block'] = $ranking_block->getBlock($rank_data);
				
				// サジェストリンクの取得
				$this->_data['suggestBlockData'] = Apm_Seo::getSuggestLinkBlockData($this->_data['bukenDtl'][0][T03_TODOUFUKEN_CD],15,5,5,15);
				// 2013/02/04 サジェストリンク追加対応 ss-sakakibaraw
				$this->_data['suggest_block'] = $this->_suggest_leftpanel_helper->getBlock($this->_data);
				
	    	    //2013/02/14 新着リンク追加対応
				$this->_data['shinchakuBlockData'] = Apm_Seo::getTenpoShinchakuBlockData($this->_data[bukenDtl][0]['T03_TENPO_CD'],0);
				$this->_data['shinchaku_block'] = $this->_shinchaku_leftpanel_helper->getBlock($this->_data);
			}
			
			// 移動 2012/05/29 H.Imamura
			// パンくずの生成
			$this->_setBreadcrumb($this->_data['bukenDtl'], $meta_data);
	
			/* 2011/07/28　AKBｷｬﾝﾍﾟｰﾝ：加盟店ﾒﾝﾊﾞｰｻｲﾄ追加対応 */
			// 加盟店ページより遷移時はパンくずを表示する
			if($this->_params['shoppage']){
				$this->_data['breadcrumb'] = $this->_breadcrumb->generateBreadcrumb();
		        $this->_data['breadcrumb'] = '<li>'.str_replace('><','></li><li><',$this->_data['breadcrumb']).'</li>';
			}
		}

		// モバイルAPIデータの作成
		$this->mobileApiAct($this->_data['bukenDtl']);
		// モバイル区分補正
		if (!empty($this->_params['isMobile']) && $this->_params['isMobile'] != '0') {
			$this->_mode = (!empty($this->_params['mode'])) ? $this->_params['mode'] : 'xml';
		}

		// 表示
		$this->display($disp_tpl);
	}


	/**
	 * キャンペーン関連パラメータを設定
	 *
	 */
	private function makeCampaignParams()
	{
    	$loader = new Zend_Application_Module_Autoloader(array(
			'namespace' => 'Inquiry',
			'basePath' => APPLICATION_PATH . '/modules/inquiry',
		));

		$model = new Inquiry_Model_BukkenEntry();

		$campaignList = $model->GetCampaignEx("2, 4", 0);

		//選択状態設定
		for ($i = 0; $i < count($campaignList); $i++)
		{
			if (array_key_exists("CampaignFlag_" . $campaignList[$i]["M94_CAMPAIGN_CD"], $this->_params))
			{
				$campaignList[$i]["selected"] = true;
			}
			else
			{
				$campaignList[$i]["selected"] = false;
			}
		}

		$this->_campaignList = $campaignList;
	}

	/**
	 * hiddenタグ生成
	 * ※キャンペーン関連パラメータ設定後に呼ぶこと
	 * @param $bukkenCnt 物件の件数
	 */
	private function makeHiddenTags($bukkenCnt)
	{
		//除外する名称配列
		$excludes
			= array(
				  "ID", "BukkenCd"//, "ComId", "OemCd", "UseKbn", "SrhKbn"
				, "NameSei", "NameMei", "Name"
				, "Mail"
				, "Tel1", "Tel2", "Tel3", "Tel", "NeedTimeKbn"
				, "Fax1", "Fax2", "Fax3", "Fax"
				, "Inquiry1", "Inquiry2", "Inquiry3", "Inquiry4", "Inquiry5", "Comment"
				, "CampaignAgechau"
			);
		//キャンペーン関連追加
		foreach ($this->_campaignList as $campaign)
		{
			$excludes[count($excludes)] = "CampaignFlag_" . $campaign["M94_CAMPAIGN_CD"];
		}
		//地図関連追加
		for ($i = 0; $i < $bukkenCnt; $i++)
		{
			$excludes[count($excludes)] = "annai" . $i;
			$excludes[count($excludes)] = "lat" . $i;
			$excludes[count($excludes)] = "lng" . $i;
		}

		//タグ生成
		$this->_hiddenTags = Apm_Util::generateHiddenTag($this->_params, $excludes);

		$excludes[count($excludes)] = "ComId";
		$excludes[count($excludes)] = "OemCd";
		$excludes[count($excludes)] = "UseKbn";
		$excludes[count($excludes)] = "SrhKbn";
		$this->_hiddenTagsInquiry = Apm_Util::generateHiddenTag($this->_params, $excludes);
	}

	/**
	 * パンくず生成
	 */
	private function _setBreadcrumb($data, $meta_data)
	{
		$breadcrumb_str = "";

		if ($this->_static_url_flg && $this->_params['buken_static'] == '1')
		//if (($this->_static_url_flg) && ($this->_params['buken_static']))
		{
			// 静的URL遷移の場合
			$params = array();
			$params['Pattern']  = 'detail';
			$params['PrefCd'][] = $data[0]['T03_TODOUFUKEN_CD'];
			$params['PrefName'] = Apm_Config_Search::$TODOUFUKEN_NAME_CODE_LIST[$data[0]['T03_TODOUFUKEN_CD']];
			$params['CityCd'][] = $data[0]['T03_TODOUFUKEN_CD'].$data[0]['T03_SHIKUCHOUSON_CD'];
			$params['TownCd'][] = $data[0]['T03_TODOUFUKEN_CD'].$data[0]['T03_SHIKUCHOUSON_CD'].$data[0]['T03_CHOUMEI_CD'];
			$params['ID'][]     = $data[0]['T03_HEYA_CD'];
			$params['COMMENT']  = $meta_data['COMMENT_STR'];
			$breadcrumb_str = Apm_Bukkenbreadcrumb::generateBreadcrumbDetail($params);
		}
		else
		{
			if ($this->_breadcrumb->getCountPankuzu() == 0) {
				$this->_breadcrumb->add(Apm_Config_Search::BREADCRUMB_TOP, $this->_config['apm']['baseurl']);
			}
			
			// 動的遷移の場合
	    	$loader = new Zend_Application_Module_Autoloader(array(
				'namespace' => 'search',
				'basePath' => APPLICATION_PATH . '/modules/search',
			));
			$model_breadcrumb = new Search_Model_Breadcrumb($this->_breadcrumb);
			//$model_breadcrumb->preUpdBeforeBreadcrumb(array());
			
			$title = "物件詳細";
			// パラメータをGET化
			// 物件詳細kodawariData処理変更
			$param = $this->_params;
			unset($param['kodawariData']);
			$url   = "/rstdtl/bukendtl". $model_breadcrumb->generateUrlParameter($param);
			$key   = "RSTDTL";
			$this->_breadcrumb->add($title, $url, $key);
			$breadcrumb_str = $this->_breadcrumb->generateBreadcrumb();
		}

		$this->setBreadCrumb($breadcrumb_str);
	}

}
?>
